<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>Chapter 10: Generic Algorithms | A君的秘密基地</title><meta name="keywords" content="C++ Primer"><meta name="author" content="astralcon"><meta name="copyright" content="astralcon"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="# Exercises Section 10.1 Ex10.1123456789101112131415161718#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;vector&gt;using namespace std;int main()&amp;#123;    int value;    int number &#x3D; 15;">
<meta property="og:type" content="article">
<meta property="og:title" content="Chapter 10: Generic Algorithms">
<meta property="og:url" content="https://astralcon.gitee.io/blog/2022/05/14/Chapter-10-Generic-Algorithms/index.html">
<meta property="og:site_name" content="A君的秘密基地">
<meta property="og:description" content="# Exercises Section 10.1 Ex10.1123456789101112131415161718#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;vector&gt;using namespace std;int main()&amp;#123;    int value;    int number &#x3D; 15;">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="">
<meta property="article:published_time" content="2022-05-14T06:26:55.000Z">
<meta property="article:modified_time" content="2022-05-14T06:57:33.876Z">
<meta property="article:author" content="astralcon">
<meta property="article:tag" content="C++ Primer">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content=""><link rel="shortcut icon" href="/blog/img/avatar.jpg"><link rel="canonical" href="https://astralcon.gitee.io/blog/2022/05/14/Chapter-10-Generic-Algorithms/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/blog/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/blog/',
  algolia: {"appId":"YUB0ZFWBBL","apiKey":"78d0f1fae31a1df3e0cb573725c55558","indexName":"blog","hits":{"per_page":6},"languages":{"input_placeholder":"搜索文章","hits_empty":"找不到您查询的内容：${query}","hits_stats":"找到 ${hits} 条结果，用时 ${time} 毫秒"}},
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Chapter 10: Generic Algorithms',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-05-14 14:57:33'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.2.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/blog/img/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">27</div></a><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">4</div></a><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">3</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 首頁</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-folder-open"></i><span> 目录</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/blog/game/"><i class="fa-fw fas fa-gamepad"></i><span> 游戏</span></a></li><li><a class="site-page child" href="/blog/book/"><i class="fa-fw fas fa-book"></i><span> 书籍</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/blog/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/blog/">A君的秘密基地</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 首頁</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-folder-open"></i><span> 目录</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/blog/game/"><i class="fa-fw fas fa-gamepad"></i><span> 游戏</span></a></li><li><a class="site-page child" href="/blog/book/"><i class="fa-fw fas fa-book"></i><span> 书籍</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/blog/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Chapter 10: Generic Algorithms</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-05-14T06:26:55.000Z" title="发表于 2022-05-14 14:26:55">2022-05-14</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-05-14T06:57:33.876Z" title="更新于 2022-05-14 14:57:33">2022-05-14</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/blog/categories/C/">C++</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-commentcount"><i class="far fa-comments fa-fw post-meta-icon"></i><span class="post-meta-label">评论数:</span><a href="/blog/2022/05/14/Chapter-10-Generic-Algorithms/#post-comment" itemprop="discussionUrl"><span class="valine-comment-count" data-xid="/blog/2022/05/14/Chapter-10-Generic-Algorithms/" itemprop="commentCount"></span></a></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><p>﻿# Exercises Section 10.1</p>
<h2 id="Ex10-1"><a href="#Ex10-1" class="headerlink" title="Ex10.1"></a>Ex10.1</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="type">int</span> value;</span><br><span class="line">    <span class="type">int</span> number = <span class="number">15</span>;</span><br><span class="line">    vector&lt;<span class="type">int</span>&gt; vec;</span><br><span class="line">    <span class="keyword">while</span> (cin &gt;&gt; value)</span><br><span class="line">        vec.<span class="built_in">push_back</span>(value);</span><br><span class="line">    <span class="keyword">auto</span> cnt = <span class="built_in">count</span>(vec.<span class="built_in">cbegin</span>(), vec.<span class="built_in">cend</span>(), number);</span><br><span class="line">    cout &lt;&lt; cnt &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-2"><a href="#Ex10-2" class="headerlink" title="Ex10.2"></a>Ex10.2</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;list&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;string&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    string word = <span class="string">&quot;astralcon&quot;</span>;</span><br><span class="line">    string value;</span><br><span class="line">    list&lt;string&gt; lst;</span><br><span class="line">    <span class="keyword">while</span> (cin &gt;&gt; value)</span><br><span class="line">        lst.<span class="built_in">push_back</span>(value);</span><br><span class="line">    <span class="keyword">auto</span> cnt = <span class="built_in">count</span>(lst.<span class="built_in">cbegin</span>(), lst.<span class="built_in">cend</span>(), word);</span><br><span class="line">    cout &lt;&lt; cnt &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h1 id="Exercises-Section-10-2-1"><a href="#Exercises-Section-10-2-1" class="headerlink" title="Exercises Section 10.2.1"></a>Exercises Section 10.2.1</h1><h2 id="Ex10-3"><a href="#Ex10-3" class="headerlink" title="Ex10.3"></a>Ex10.3</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;numeric&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="type">int</span> value;</span><br><span class="line">    vector&lt;<span class="type">int</span>&gt; vec;</span><br><span class="line">    <span class="keyword">while</span> (cin &gt;&gt; value)</span><br><span class="line">        vec.<span class="built_in">push_back</span>(value);</span><br><span class="line">    <span class="type">int</span> sum = <span class="built_in">accumulate</span>(vec.<span class="built_in">cbegin</span>(), vec.<span class="built_in">cend</span>(), <span class="number">0</span>);</span><br><span class="line">    cout &lt;&lt; sum &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-4"><a href="#Ex10-4" class="headerlink" title="Ex10.4"></a>Ex10.4</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">accumulate函数的第三个参数决定了该函数的返回类型，由于 v 为 vector&lt;<span class="type">double</span>&gt;，故第三个参数为 <span class="type">int</span> 类型的值 <span class="number">0</span> 应该改为 <span class="type">double</span> 类型的值 <span class="number">0.0</span></span><br></pre></td></tr></table></figure>

<h2 id="Ex10-5"><a href="#Ex10-5" class="headerlink" title="Ex10.5"></a>Ex10.5</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">如果所有的 rosters 都变为 <span class="type">char</span> *类型，那么 equal函数就是比较两个指针的地址是否相同，而不是比较两个指针指向的对象内容是否相等</span><br></pre></td></tr></table></figure>

<h1 id="Exercises-Section-10-2-2"><a href="#Exercises-Section-10-2-2" class="headerlink" title="Exercises Section 10.2.2"></a>Exercises Section 10.2.2</h1><h2 id="Ex10-6"><a href="#Ex10-6" class="headerlink" title="Ex10.6"></a>Ex10.6</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    vector&lt;<span class="type">double</span>&gt; vec = &#123;<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>&#125;;</span><br><span class="line">    <span class="built_in">fill_n</span>(vec.<span class="built_in">begin</span>(), <span class="number">10</span>, <span class="number">0</span>);</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">double</span> d : vec)</span><br><span class="line">        cout &lt;&lt; d &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-7"><a href="#Ex10-7" class="headerlink" title="Ex10.7"></a>Ex10.7</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">a)  <span class="comment">// 错误；必须保证目的容器的元素数量范围至少与输入容器元素数量范围相等</span></span><br><span class="line">	vector&lt;<span class="type">int</span>&gt; vec;</span><br><span class="line">    list&lt;<span class="type">int</span>&gt; lst;</span><br><span class="line">    <span class="type">int</span> i;</span><br><span class="line">    <span class="keyword">while</span> (cin &gt;&gt; i)</span><br><span class="line">        lst.<span class="built_in">push_back</span>(i);</span><br><span class="line">    <span class="built_in">copy</span>(lst.<span class="built_in">cbegin</span>(), lst.<span class="built_in">cend</span>(), vec.<span class="built_in">begin</span>());</span><br><span class="line"></span><br><span class="line">b)  <span class="comment">// 错误；reserve 只是给容器预分配了容纳10个 int 元素的空间，容器内元素数量还是为0，而 fill_n 作用于空容器的结果是未定义的</span></span><br><span class="line">	vector&lt;<span class="type">int</span>&gt; vec;</span><br><span class="line">    vec.<span class="built_in">reserve</span>(<span class="number">10</span>);    </span><br><span class="line">    <span class="built_in">fill_n</span>(vec.<span class="built_in">begin</span>(), <span class="number">10</span>, <span class="number">0</span>);</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-8"><a href="#Ex10-8" class="headerlink" title="Ex10.8"></a>Ex10.8</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">back_inserter 定义在 iterator 头文件中而不是 algorithm 头文件中；</span><br><span class="line">algorithm 中的方法不能改变容器元素数量，但是迭代器可以。</span><br></pre></td></tr></table></figure>

<h1 id="Exercises-Section-10-2-3"><a href="#Exercises-Section-10-2-3" class="headerlink" title="Exercises Section 10.2.3"></a>Exercises Section 10.2.3</h1><h2 id="Ex10-9"><a href="#Ex10-9" class="headerlink" title="Ex10.9"></a>Ex10.9</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;string&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">elimDups</span><span class="params">(vector&lt;string&gt; &amp;words)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="built_in">sort</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>());</span><br><span class="line">    <span class="keyword">auto</span> end_unique = <span class="built_in">unique</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>());</span><br><span class="line">    words.<span class="built_in">erase</span>(end_unique, words.<span class="built_in">end</span>());</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    vector&lt;string&gt; vec;</span><br><span class="line">    string word;</span><br><span class="line">    <span class="keyword">while</span> (cin &gt;&gt; word)</span><br><span class="line">        vec.<span class="built_in">push_back</span>(word);</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">const</span> string &amp;s : vec)</span><br><span class="line">        cout &lt;&lt; s &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;===after call elimDups===&quot;</span> &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">elimDups</span>(vec);</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">const</span> string &amp;s: vec)</span><br><span class="line">        cout &lt;&lt; s &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-10"><a href="#Ex10-10" class="headerlink" title="Ex10.10"></a>Ex10.10</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">泛型算法可以用于不同类型的容器，通过迭代器对容器进行访问，即使改变了容器的元素数量大小，也是迭代器的作用而不是泛型算法。</span><br></pre></td></tr></table></figure>

<h1 id="Exercises-Section-10-3-1"><a href="#Exercises-Section-10-3-1" class="headerlink" title="Exercises Section 10.3.1"></a>Exercises Section 10.3.1</h1><h2 id="Ex10-11"><a href="#Ex10-11" class="headerlink" title="Ex10.11"></a>Ex10.11</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;string&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">elimDups</span><span class="params">(vector&lt;string&gt; &amp;words)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="built_in">sort</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>());</span><br><span class="line">    <span class="keyword">auto</span> end_unique = <span class="built_in">unique</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>());</span><br><span class="line">    words.<span class="built_in">erase</span>(end_unique, words.<span class="built_in">end</span>());</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">isShorter</span><span class="params">(<span class="type">const</span> string &amp;s1, <span class="type">const</span> string &amp;s2)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">return</span> s1.<span class="built_in">size</span>() &lt; s2.<span class="built_in">size</span>();</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    vector&lt;string&gt; words;</span><br><span class="line">    string word;</span><br><span class="line">    <span class="keyword">while</span> (cin &gt;&gt; word)</span><br><span class="line">        words.<span class="built_in">push_back</span>(word);</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">const</span> string &amp;s : words)</span><br><span class="line">        cout &lt;&lt; s &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">elimDups</span>(words);</span><br><span class="line">    <span class="built_in">stable_sort</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>(), isShorter);</span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;================&quot;</span> &lt;&lt; endl;</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">const</span> string &amp;s : words)</span><br><span class="line">        cout &lt;&lt; s &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-12"><a href="#Ex10-12" class="headerlink" title="Ex10.12"></a>Ex10.12</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;Sales_item.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">compareIsbn</span><span class="params">(<span class="type">const</span> Sales_data &amp;s1, <span class="type">const</span> Sales_data &amp;s2)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">return</span> s1.<span class="built_in">isbn</span>() &lt; s2.<span class="built_in">isbn</span>();</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    vector&lt;Sales_data&gt; vec;</span><br><span class="line">    Sales_data sd;</span><br><span class="line">    <span class="keyword">while</span> (<span class="built_in">read</span>(cin, sd))</span><br><span class="line">        vec.<span class="built_in">push_back</span>(sd);</span><br><span class="line">    <span class="built_in">sort</span>(vec.<span class="built_in">begin</span>(), vec.<span class="built_in">end</span>(), compareIsbn);</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">const</span> <span class="keyword">auto</span> &amp;s : vec)</span><br><span class="line">        cout &lt;&lt; s &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-13"><a href="#Ex10-13" class="headerlink" title="Ex10.13"></a>Ex10.13</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;string&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">isLonger</span><span class="params">(<span class="type">const</span> string &amp;s)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">return</span> s.<span class="built_in">size</span>() &gt;= <span class="number">5</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    vector&lt;string&gt; words;</span><br><span class="line">    string word;</span><br><span class="line">    <span class="keyword">while</span> (cin &gt;&gt; word)</span><br><span class="line">        words.<span class="built_in">push_back</span>(word);</span><br><span class="line">    <span class="keyword">auto</span> pos = <span class="built_in">partition</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>(), isLonger);</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">auto</span> beg = words.<span class="built_in">begin</span>(); beg != pos; ++beg)</span><br><span class="line">        cout &lt;&lt; *beg &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h1 id="Exercises-Section-10-3-2"><a href="#Exercises-Section-10-3-2" class="headerlink" title="Exercises Section 10.3.2"></a>Exercises Section 10.3.2</h1><h2 id="Ex10-14"><a href="#Ex10-14" class="headerlink" title="Ex10.14"></a>Ex10.14</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="type">int</span> a = <span class="number">1</span>, b = <span class="number">2</span>;</span><br><span class="line">    <span class="keyword">auto</span> f = [](<span class="type">int</span> a,<span class="type">int</span> b) &#123; <span class="keyword">return</span> a + b; &#125;;</span><br><span class="line">    cout &lt;&lt; <span class="built_in">f</span>(a, b) &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-15"><a href="#Ex10-15" class="headerlink" title="Ex10.15"></a>Ex10.15</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="type">int</span> a = <span class="number">1</span>, b = <span class="number">2</span>;</span><br><span class="line">    <span class="keyword">auto</span> f = [a](<span class="type">int</span> b) &#123; <span class="keyword">return</span> a + b; &#125;;</span><br><span class="line">    cout &lt;&lt; <span class="built_in">f</span>(b) &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-16"><a href="#Ex10-16" class="headerlink" title="Ex10.16"></a>Ex10.16</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="type">void</span> <span class="title">biggies</span><span class="params">(vector&lt;string&gt; &amp;words, vector&lt;string&gt;::size_type sz)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="built_in">elimDups</span>(words);</span><br><span class="line">    <span class="built_in">stable_sort</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>(), [](<span class="type">const</span> string &amp;a, <span class="type">const</span> string &amp;b) &#123;<span class="keyword">return</span> a.<span class="built_in">size</span>() &lt; b.<span class="built_in">size</span>();&#125;);</span><br><span class="line">    <span class="keyword">auto</span> wc = <span class="built_in">find_if</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>(), [sz](<span class="type">const</span> string &amp;a) &#123;<span class="keyword">return</span> a.<span class="built_in">size</span>() &gt;= sz;&#125;);</span><br><span class="line">    <span class="keyword">auto</span> count = words.<span class="built_in">end</span>() - wc;</span><br><span class="line">    cout &lt;&lt; count &lt;&lt; <span class="string">&quot; &quot;</span> &lt;&lt; <span class="built_in">make_plural</span>(count, <span class="string">&quot;word&quot;</span>, <span class="string">&quot;s&quot;</span>) &lt;&lt; <span class="string">&quot; of length &quot;</span> &lt;&lt; sz &lt;&lt; <span class="string">&quot; or longer&quot;</span> &lt;&lt; endl;</span><br><span class="line">    for_each(wc, words.<span class="built_in">end</span>(), [](<span class="type">const</span> string &amp;s) &#123;cout &lt;&lt; s &lt;&lt; <span class="string">&quot; &quot;</span>;&#125;);</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-17"><a href="#Ex10-17" class="headerlink" title="Ex10.17"></a>Ex10.17</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;Sales_item.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    vector&lt;Sales_data&gt; vec;</span><br><span class="line">    Sales_data sd;</span><br><span class="line">    <span class="keyword">while</span> (<span class="built_in">read</span>(cin, sd))</span><br><span class="line">        vec.<span class="built_in">push_back</span>(sd);</span><br><span class="line">    <span class="built_in">sort</span>(vec.<span class="built_in">begin</span>(), vec.<span class="built_in">end</span>(), [](<span class="type">const</span> Sales_data &amp;s1, <span class="type">const</span> Sales_data &amp;s2) &#123;<span class="keyword">return</span> s1.<span class="built_in">isbn</span>() &lt; s2.<span class="built_in">isbn</span>();&#125;);</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">const</span> <span class="keyword">auto</span> &amp;s : vec)</span><br><span class="line">        cout &lt;&lt; s &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-18"><a href="#Ex10-18" class="headerlink" title="Ex10.18"></a>Ex10.18</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="type">void</span> <span class="title">biggies</span><span class="params">(vector&lt;string&gt; &amp;words, vector&lt;string&gt;::size_type sz)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="built_in">elimDups</span>(words);</span><br><span class="line">    <span class="built_in">stable_sort</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>(), [](<span class="type">const</span> string &amp;a, <span class="type">const</span> string &amp;b) &#123;<span class="keyword">return</span> a.<span class="built_in">size</span>() &lt; b.<span class="built_in">size</span>();&#125;);</span><br><span class="line">    <span class="keyword">auto</span> wc = <span class="built_in">partition</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>(), [sz](<span class="type">const</span> string &amp;a) &#123;<span class="keyword">return</span> a.<span class="built_in">size</span>() &gt;= sz;&#125;);</span><br><span class="line">    <span class="keyword">auto</span> count = words.<span class="built_in">end</span>() - wc;</span><br><span class="line">    cout &lt;&lt; count &lt;&lt; <span class="string">&quot; &quot;</span> &lt;&lt; <span class="built_in">make_plural</span>(count, <span class="string">&quot;word&quot;</span>, <span class="string">&quot;s&quot;</span>) &lt;&lt; <span class="string">&quot; of length &quot;</span> &lt;&lt; sz &lt;&lt; <span class="string">&quot; or longer&quot;</span> &lt;&lt; endl;</span><br><span class="line">    for_each(wc, words.<span class="built_in">end</span>(), [](<span class="type">const</span> string &amp;s) &#123;cout &lt;&lt; s &lt;&lt; <span class="string">&quot; &quot;</span>;&#125;);</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-19"><a href="#Ex10-19" class="headerlink" title="Ex10.19"></a>Ex10.19</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="type">void</span> <span class="title">biggies</span><span class="params">(vector&lt;string&gt; &amp;words, vector&lt;string&gt;::size_type sz)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="built_in">elimDups</span>(words);</span><br><span class="line">    <span class="built_in">stable_sort</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>(), [](<span class="type">const</span> string &amp;a, <span class="type">const</span> string &amp;b) &#123;<span class="keyword">return</span> a.<span class="built_in">size</span>() &lt; b.<span class="built_in">size</span>();&#125;);</span><br><span class="line">    <span class="keyword">auto</span> wc = <span class="built_in">stable_partition</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>(), [sz](<span class="type">const</span> string &amp;a) &#123;<span class="keyword">return</span> a.<span class="built_in">size</span>() &gt;= sz;&#125;);</span><br><span class="line">    <span class="keyword">auto</span> count = words.<span class="built_in">end</span>() - wc;</span><br><span class="line">    cout &lt;&lt; count &lt;&lt; <span class="string">&quot; &quot;</span> &lt;&lt; <span class="built_in">make_plural</span>(count, <span class="string">&quot;word&quot;</span>, <span class="string">&quot;s&quot;</span>) &lt;&lt; <span class="string">&quot; of length &quot;</span> &lt;&lt; sz &lt;&lt; <span class="string">&quot; or longer&quot;</span> &lt;&lt; endl;</span><br><span class="line">    for_each(wc, words.<span class="built_in">end</span>(), [](<span class="type">const</span> string &amp;s) &#123;cout &lt;&lt; s &lt;&lt; <span class="string">&quot; &quot;</span>;&#125;);</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h1 id="Exercises-Section-10-3-3"><a href="#Exercises-Section-10-3-3" class="headerlink" title="Exercises Section 10.3.3"></a>Exercises Section 10.3.3</h1><h2 id="Ex10-20"><a href="#Ex10-20" class="headerlink" title="Ex10.20"></a>Ex10.20</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;string&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    vector&lt;string&gt; vec;</span><br><span class="line">    string word;</span><br><span class="line">    <span class="keyword">while</span> (cin &gt;&gt; word)</span><br><span class="line">        vec.<span class="built_in">push_back</span>(word);</span><br><span class="line">    <span class="keyword">auto</span> f = <span class="built_in">count_if</span>(vec.<span class="built_in">begin</span>(), vec.<span class="built_in">end</span>(), [](<span class="type">const</span> string &amp;s) &#123;<span class="keyword">return</span> s.<span class="built_in">size</span>() &gt; <span class="number">6</span>;&#125;);</span><br><span class="line">    cout &lt;&lt; f &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-21"><a href="#Ex10-21" class="headerlink" title="Ex10.21"></a>Ex10.21</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="type">int</span> value;</span><br><span class="line">    cin &gt;&gt; value;</span><br><span class="line">    <span class="keyword">auto</span> f = [&amp; value]() <span class="keyword">mutable</span> -&gt; <span class="type">bool</span> &#123;<span class="keyword">if</span>(value != <span class="number">0</span>) &#123;<span class="keyword">return</span> <span class="literal">false</span>; --value;&#125; <span class="keyword">else</span> <span class="keyword">return</span> <span class="literal">true</span>;&#125;;</span><br><span class="line">    cout &lt;&lt; <span class="built_in">f</span>() &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h1 id="Exercises-Section-10-3-4"><a href="#Exercises-Section-10-3-4" class="headerlink" title="Exercises Section 10.3.4"></a>Exercises Section 10.3.4</h1><h2 id="Ex10-22"><a href="#Ex10-22" class="headerlink" title="Ex10.22"></a>Ex10.22</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;string&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;numeric&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;functional&gt;</span></span></span><br><span class="line"> </span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> placeholders;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">elimdups</span><span class="params">(vector&lt;string&gt; &amp;words)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="built_in">sort</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>());</span><br><span class="line">	<span class="keyword">auto</span> end_unique = <span class="built_in">unique</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>());</span><br><span class="line">	words.<span class="built_in">erase</span>(end_unique, words.<span class="built_in">end</span>());</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">check_size</span><span class="params">(<span class="type">const</span> string &amp;s, string::size_type sz)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">return</span> s.<span class="built_in">size</span>() &gt; sz;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">ishorter</span><span class="params">(<span class="type">const</span> string &amp;s1, <span class="type">const</span> string &amp;s2)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">return</span> s1.<span class="built_in">size</span>() &lt; s2.<span class="built_in">size</span>();</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function">ostream &amp; <span class="title">print</span><span class="params">(ostream &amp;os, <span class="type">const</span> string &amp;s, <span class="type">char</span> c)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">return</span> os &lt;&lt; s &lt;&lt; c;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">biggies</span><span class="params">(vector&lt;string&gt; &amp;words, vector&lt;string&gt;::size_type sz)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="built_in">elimdups</span>(words); </span><br><span class="line">	<span class="built_in">stable_sort</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>(), <span class="built_in">bind</span>(ishorter,_1,_2));</span><br><span class="line">	<span class="keyword">auto</span> wc = <span class="built_in">find_if</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>(), <span class="built_in">bind</span>(check_size, _1, sz));</span><br><span class="line">	<span class="keyword">auto</span> count = words.<span class="built_in">end</span>() - wc;</span><br><span class="line">	for_each(wc, words.<span class="built_in">end</span>(), <span class="built_in">bind</span>(print,<span class="built_in">ref</span>(cout), _1, <span class="string">&#x27; &#x27;</span>));</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">(<span class="type">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	vector&lt;string&gt; words;</span><br><span class="line">	string word;</span><br><span class="line">	<span class="keyword">while</span> (cin &gt;&gt; word)</span><br><span class="line">	&#123;</span><br><span class="line">		words.<span class="built_in">push_back</span>(word);</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">biggies</span>(words, <span class="number">5</span>);</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-23"><a href="#Ex10-23" class="headerlink" title="Ex10.23"></a>Ex10.23</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">two arguments</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-24"><a href="#Ex10-24" class="headerlink" title="Ex10.24"></a>Ex10.24</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;functional&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;string&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> placeholders;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">check_size</span><span class="params">(<span class="type">const</span> string &amp;s1, string::size_type sz)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">return</span> s1.<span class="built_in">size</span>() &lt; sz;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">(<span class="type">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="function">string <span class="title">s1</span><span class="params">(<span class="string">&quot;hello&quot;</span>)</span></span>;</span><br><span class="line">	vector&lt;<span class="type">int</span>&gt; vec1 = &#123; <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>, <span class="number">10</span>, <span class="number">11</span>, <span class="number">12</span> &#125;;</span><br><span class="line">	<span class="keyword">auto</span> wc = <span class="built_in">find_if</span>(vec1.<span class="built_in">begin</span>(), vec1.<span class="built_in">end</span>(), <span class="built_in">bind</span>(check_size, s1,_1));</span><br><span class="line">	<span class="type">int</span> count = vec1.<span class="built_in">end</span>() - wc;</span><br><span class="line">	cout &lt;&lt; <span class="string">&quot;vec1中第&quot;</span> &lt;&lt;vec1.<span class="built_in">size</span>()-count &lt;&lt; <span class="string">&quot;个第一个大于string长度&quot;</span> &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-25"><a href="#Ex10-25" class="headerlink" title="Ex10.25"></a>Ex10.25</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;string&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;numeric&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;functional&gt;</span></span></span><br><span class="line"> </span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> placeholders;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">elimdups</span><span class="params">(vector&lt;string&gt; &amp;words)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="built_in">sort</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>());</span><br><span class="line">	<span class="keyword">auto</span> end_unique = <span class="built_in">unique</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>());</span><br><span class="line">	words.<span class="built_in">erase</span>(end_unique, words.<span class="built_in">end</span>());</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function">ostream &amp;<span class="title">print</span><span class="params">(ostream &amp;os,<span class="type">const</span> string &amp;s, <span class="type">const</span> <span class="type">char</span> c)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">return</span> os &lt;&lt; s &lt;&lt; c;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">check_size</span><span class="params">(<span class="type">const</span> string &amp; s, string::size_type sz)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">return</span> s.<span class="built_in">size</span>() &gt; sz;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">biggies</span><span class="params">(vector&lt;string&gt; &amp; words, vector&lt;string&gt;::size_type sz)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="built_in">elimdups</span>(words); </span><br><span class="line">	for_each(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>(), <span class="built_in">bind</span>(print,<span class="built_in">ref</span>(cout),_1,<span class="string">&#x27; &#x27;</span>));</span><br><span class="line">	cout &lt;&lt; endl;</span><br><span class="line">	<span class="keyword">auto</span> wc = <span class="built_in">partition</span>(words.<span class="built_in">begin</span>(), words.<span class="built_in">end</span>(), <span class="built_in">bind</span>(check_size,_1,sz));</span><br><span class="line">	for_each(words.<span class="built_in">begin</span>(),wc, <span class="built_in">bind</span>(print, <span class="built_in">ref</span>(cout), _1, <span class="string">&#x27; &#x27;</span>));</span><br><span class="line">	cout &lt;&lt; endl;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">(<span class="type">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	vector&lt;string&gt; words&#123; <span class="string">&quot;the&quot;</span>, <span class="string">&quot;quick&quot;</span>, <span class="string">&quot;red&quot;</span>, <span class="string">&quot;fox&quot;</span>, <span class="string">&quot;jumps&quot;</span>, <span class="string">&quot;over&quot;</span>, <span class="string">&quot;the&quot;</span>, <span class="string">&quot;slow&quot;</span>, <span class="string">&quot;red&quot;</span>, <span class="string">&quot;turtle&quot;</span> &#125;;</span><br><span class="line">	<span class="built_in">biggies</span>(words, <span class="number">4</span>);</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h1 id="Exercises-Section-10-4-1"><a href="#Exercises-Section-10-4-1" class="headerlink" title="Exercises Section 10.4.1"></a>Exercises Section 10.4.1</h1><h2 id="Ex10-26"><a href="#Ex10-26" class="headerlink" title="Ex10.26"></a>Ex10.26</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">back_inserter：创建一个使用 push_back的迭代器</span><br><span class="line">front_inserter：创建一个使用push_front的迭代器</span><br><span class="line">inserter：创建一个使用insert的迭代器</span><br><span class="line">front_inserter产生一个迭代器使插入的顺序相反；而back_inserter和inserter则不会。</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-27"><a href="#Ex10-27" class="headerlink" title="Ex10.27"></a>Ex10.27</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;list&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    vector&lt;<span class="type">int</span>&gt; vec = &#123;<span class="number">1</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>&#125;;</span><br><span class="line">    list&lt;<span class="type">int</span>&gt; lst;</span><br><span class="line">    lst.<span class="built_in">resize</span>(vec.<span class="built_in">size</span>());</span><br><span class="line">    <span class="built_in">unique_copy</span>(vec.<span class="built_in">begin</span>(), vec.<span class="built_in">end</span>(), lst.<span class="built_in">begin</span>());</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">const</span> <span class="keyword">auto</span> &amp;i : lst)</span><br><span class="line">        cout &lt;&lt; i &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-28"><a href="#Ex10-28" class="headerlink" title="Ex10.28"></a>Ex10.28</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;list&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    vector&lt;<span class="type">int</span>&gt; vec = &#123;<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>&#125;;</span><br><span class="line">    vector&lt;<span class="type">int</span>&gt; v1, v3;</span><br><span class="line">    list&lt;<span class="type">int</span>&gt; v2;</span><br><span class="line">    <span class="built_in">copy</span>(vec.<span class="built_in">cbegin</span>(), vec.<span class="built_in">cend</span>(), <span class="built_in">back_inserter</span>(v1));</span><br><span class="line">    <span class="built_in">copy</span>(vec.<span class="built_in">cbegin</span>(), vec.<span class="built_in">cend</span>(), <span class="built_in">front_inserter</span>(v2));</span><br><span class="line">    <span class="built_in">copy</span>(vec.<span class="built_in">cbegin</span>(), vec.<span class="built_in">cend</span>(), <span class="built_in">inserter</span>(v3, v3.<span class="built_in">begin</span>()));</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">const</span> <span class="keyword">auto</span> &amp;i : v1)</span><br><span class="line">        cout &lt;&lt; i &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">const</span> <span class="keyword">auto</span> &amp;i : v2)</span><br><span class="line">        cout &lt;&lt; i &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">const</span> <span class="keyword">auto</span> &amp;i : v3)</span><br><span class="line">        cout &lt;&lt; i &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h1 id="Exercises-Section-10-4-3"><a href="#Exercises-Section-10-4-3" class="headerlink" title="Exercises Section 10.4.3"></a>Exercises Section 10.4.3</h1><h2 id="Ex10-34"><a href="#Ex10-34" class="headerlink" title="Ex10.34"></a>Ex10.34</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    vector&lt;<span class="type">int</span>&gt; vec;</span><br><span class="line">    <span class="type">int</span> value;</span><br><span class="line">    <span class="keyword">while</span> (cin &gt;&gt; value)</span><br><span class="line">        vec.<span class="built_in">push_back</span>(value);</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">auto</span> r_iter = vec.<span class="built_in">crbegin</span>(); r_iter != vec.<span class="built_in">crend</span>(); ++r_iter)</span><br><span class="line">        cout &lt;&lt; *r_iter &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-35"><a href="#Ex10-35" class="headerlink" title="Ex10.35"></a>Ex10.35</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    vector&lt;<span class="type">int</span>&gt; vec;</span><br><span class="line">    <span class="type">int</span> value;</span><br><span class="line">    <span class="keyword">while</span> (cin &gt;&gt; value)</span><br><span class="line">        vec.<span class="built_in">push_back</span>(value);</span><br><span class="line">    vector&lt;<span class="type">int</span>&gt;::iterator it = vec.<span class="built_in">end</span>();</span><br><span class="line">    <span class="keyword">do</span> </span><br><span class="line">    &#123;</span><br><span class="line">        --it;</span><br><span class="line">        cout &lt;&lt; *it &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    &#125; <span class="keyword">while</span> (it != vec.<span class="built_in">begin</span>());</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-36"><a href="#Ex10-36" class="headerlink" title="Ex10.36"></a>Ex10.36</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;list&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    list&lt;<span class="type">int</span>&gt; lst;</span><br><span class="line">    <span class="type">int</span> value;</span><br><span class="line">    <span class="keyword">while</span> (cin &gt;&gt; value)</span><br><span class="line">        lst.<span class="built_in">push_back</span>(value);</span><br><span class="line">    <span class="keyword">auto</span> pos = <span class="built_in">find</span>(lst.<span class="built_in">crbegin</span>(), lst.<span class="built_in">crend</span>(), <span class="number">0</span>);</span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;Output elements after the last element in a list with value zero: &quot;</span>;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">auto</span> iter = pos.<span class="built_in">base</span>(); iter != lst.<span class="built_in">cend</span>(); ++iter)</span><br><span class="line">        cout &lt;&lt; *iter &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-37"><a href="#Ex10-37" class="headerlink" title="Ex10.37"></a>Ex10.37</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;list&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;vector&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    vector&lt;<span class="type">int</span>&gt; vec = &#123;<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>&#125;;</span><br><span class="line">    list&lt;<span class="type">int</span>&gt; lst;</span><br><span class="line">    <span class="built_in">copy</span>(vec.<span class="built_in">crbegin</span>() + <span class="number">2</span>, vec.<span class="built_in">crbegin</span>() + <span class="number">7</span>, <span class="built_in">back_inserter</span>(lst));</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">const</span> <span class="type">int</span> &amp;i : lst)</span><br><span class="line">        cout &lt;&lt; i &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h1 id="Exercises-Section-10-5-1"><a href="#Exercises-Section-10-5-1" class="headerlink" title="Exercises Section 10.5.1"></a>Exercises Section 10.5.1</h1><h2 id="Ex10-38"><a href="#Ex10-38" class="headerlink" title="Ex10.38"></a>Ex10.38</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">input iterator: 只读不写，单遍扫描，只递增；支持 == != 前缀和后缀++ 解引用* 箭头操作 -&gt; </span><br><span class="line">output iterator: 只写不读，单遍扫描，只递增；支持前缀和后缀++ 解引用*</span><br><span class="line">forward iterator: 可读写，多遍扫描，只递增；支持所有输入输出迭代器操作</span><br><span class="line">bidirectional iterator: 可读写，多遍扫描，可递增递减；支持所有 forward iterator 的操作，加上前置和后置--</span><br><span class="line">random-access iterator: 可读写，多遍扫描，支持上述全部迭代器运算，外加关系运算符、迭代器减法、下标运算符</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-39"><a href="#Ex10-39" class="headerlink" title="Ex10.39"></a>Ex10.39</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">list: bidirectional iterator</span><br><span class="line">vector: random-access iterator</span><br></pre></td></tr></table></figure>

<h2 id="Ex10-40"><a href="#Ex10-40" class="headerlink" title="Ex10.40"></a>Ex10.40</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">copy：前两个参数至少为输入迭代器，第三个参数至少为输出迭代器</span><br><span class="line">reverse：两个参数至少为 forward iterator</span><br></pre></td></tr></table></figure>

<h1 id="Exercises-Section-10-5-3"><a href="#Exercises-Section-10-5-3" class="headerlink" title="Exercises Section 10.5.3"></a>Exercises Section 10.5.3</h1><h2 id="Ex10-41"><a href="#Ex10-41" class="headerlink" title="Ex10.41"></a>Ex10.41</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">replace</span>(beg, end, old_val, new_val);	<span class="comment">// 将[beg, end)中的 old_val 替换为 new_val</span></span><br><span class="line"><span class="built_in">replace_if</span>(beg, end, pred, new_val);	<span class="comment">// 将[beg, end)中满足 pred 的元素值替换为 new_val</span></span><br><span class="line"><span class="built_in">replace_copy</span>(beg, end, dest, old_val, new_val);	<span class="comment">// 将[beg, end)的元素复制到 dest，并将其值为 old_val 的元素替换为 new_val</span></span><br><span class="line"><span class="built_in">replace_copy_if</span>(beg, end, dest, pred, new_val);	<span class="comment">// 将[beg, end)的元素复制到 dest，并将满足 pred 的元素值替换为 new_val</span></span><br></pre></td></tr></table></figure>

<h1 id="Exercises-Section-10-6"><a href="#Exercises-Section-10-6" class="headerlink" title="Exercises Section 10.6"></a>Exercises Section 10.6</h1><h2 id="Ex10-42"><a href="#Ex10-42" class="headerlink" title="Ex10.42"></a>Ex10.42</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string">&lt;list&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">elimDups</span><span class="params">(list&lt;string&gt; &amp;words)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    words.<span class="built_in">sort</span>();</span><br><span class="line">    words.<span class="built_in">unique</span>();</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    list&lt;string&gt; words;</span><br><span class="line">    string  word;</span><br><span class="line">    <span class="keyword">while</span> (cin &gt;&gt; word)</span><br><span class="line">        words.<span class="built_in">push_back</span>(word);</span><br><span class="line">    <span class="built_in">elimDups</span>(words);</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">const</span> string &amp;s : words)</span><br><span class="line">        cout &lt;&lt; s &lt;&lt; <span class="string">&quot; &quot;</span>;</span><br><span class="line">    cout &lt;&lt; endl;</span><br><span class="line">    <span class="built_in">system</span>(<span class="string">&quot;pause&quot;</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://astralcon.gitee.io/blog">astralcon</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://astralcon.gitee.io/blog/2022/05/14/Chapter-10-Generic-Algorithms/">https://astralcon.gitee.io/blog/2022/05/14/Chapter-10-Generic-Algorithms/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://astralcon.gitee.io/blog" target="_blank">A君的秘密基地</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/blog/tags/C-Primer/">C++ Primer</a></div><div class="post_share"><div class="social-share" data-image="" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/gh/overtrue/share.js@master/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/blog/img/wechat.jpg" target="_blank"><img class="post-qr-code-img" src="/blog/img/wechat.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/blog/img/alipay.jpg" target="_blank"><img class="post-qr-code-img" src="/blog/img/alipay.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/blog/2022/05/14/Chapter-11-Associative-Containers/"><img class="prev-cover" src="" onerror="onerror=null;src='/blog/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Chapter 11: Associative Containers</div></div></a></div><div class="next-post pull-right"><a href="/blog/2022/05/14/Chapter-9-Sequential-Containers/"><img class="next-cover" src="" onerror="onerror=null;src='/blog/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Chapter 9: Sequential Containers</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/blog/2022/05/14/Chapter-1-Getting-Started/" title="Chapter 1: Getting Started"><img class="cover" src="" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-05-14</div><div class="title">Chapter 1: Getting Started</div></div></a></div><div><a href="/blog/2022/05/14/Chapter-11-Associative-Containers/" title="Chapter 11: Associative Containers"><img class="cover" src="" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-05-14</div><div class="title">Chapter 11: Associative Containers</div></div></a></div><div><a href="/blog/2022/05/14/Chapter-12-Dynamic-Memory/" title="Chapter 12: Dynamic Memory"><img class="cover" src="" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-05-14</div><div class="title">Chapter 12: Dynamic Memory</div></div></a></div><div><a href="/blog/2022/05/14/Chapter-13-Copy-Control/" title="Chapter 13: Copy Control"><img class="cover" src="" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-05-14</div><div class="title">Chapter 13: Copy Control</div></div></a></div><div><a href="/blog/2022/05/14/Chapter-15-Object-Oriented-Programming/" title="Chapter 15: Object-Oriented Programming"><img class="cover" src="" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-05-14</div><div class="title">Chapter 15: Object-Oriented Programming</div></div></a></div><div><a href="/blog/2022/05/14/Chapter-14-Overloaded-Operations-And-Conversions/" title="Chapter 14: Overloaded Operations And Conversions"><img class="cover" src="" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-05-14</div><div class="title">Chapter 14: Overloaded Operations And Conversions</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div><div id="comment-switch"><span class="first-comment">Valine</span><span class="switch-btn"></span><span class="second-comment">Disqus</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div><div><div id="disqus_thread"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/blog/img/avatar.jpg" onerror="this.onerror=null;this.src='/blog/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">astralcon</div><div class="author-info__description">slow is fast.</div></div><div class="card-info-data site-data is-center"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">27</div></a><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">4</div></a><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">3</div></a></div><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/astralcon" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:a842181471@qq.com.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">朝九晚五，健康生活！</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-1"><span class="toc-number">1.</span> <span class="toc-text">Ex10.1</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-2"><span class="toc-number">2.</span> <span class="toc-text">Ex10.2</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Exercises-Section-10-2-1"><span class="toc-number"></span> <span class="toc-text">Exercises Section 10.2.1</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-3"><span class="toc-number">1.</span> <span class="toc-text">Ex10.3</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-4"><span class="toc-number">2.</span> <span class="toc-text">Ex10.4</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-5"><span class="toc-number">3.</span> <span class="toc-text">Ex10.5</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Exercises-Section-10-2-2"><span class="toc-number"></span> <span class="toc-text">Exercises Section 10.2.2</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-6"><span class="toc-number">1.</span> <span class="toc-text">Ex10.6</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-7"><span class="toc-number">2.</span> <span class="toc-text">Ex10.7</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-8"><span class="toc-number">3.</span> <span class="toc-text">Ex10.8</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Exercises-Section-10-2-3"><span class="toc-number"></span> <span class="toc-text">Exercises Section 10.2.3</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-9"><span class="toc-number">1.</span> <span class="toc-text">Ex10.9</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-10"><span class="toc-number">2.</span> <span class="toc-text">Ex10.10</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Exercises-Section-10-3-1"><span class="toc-number"></span> <span class="toc-text">Exercises Section 10.3.1</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-11"><span class="toc-number">1.</span> <span class="toc-text">Ex10.11</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-12"><span class="toc-number">2.</span> <span class="toc-text">Ex10.12</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-13"><span class="toc-number">3.</span> <span class="toc-text">Ex10.13</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Exercises-Section-10-3-2"><span class="toc-number"></span> <span class="toc-text">Exercises Section 10.3.2</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-14"><span class="toc-number">1.</span> <span class="toc-text">Ex10.14</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-15"><span class="toc-number">2.</span> <span class="toc-text">Ex10.15</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-16"><span class="toc-number">3.</span> <span class="toc-text">Ex10.16</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-17"><span class="toc-number">4.</span> <span class="toc-text">Ex10.17</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-18"><span class="toc-number">5.</span> <span class="toc-text">Ex10.18</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-19"><span class="toc-number">6.</span> <span class="toc-text">Ex10.19</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Exercises-Section-10-3-3"><span class="toc-number"></span> <span class="toc-text">Exercises Section 10.3.3</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-20"><span class="toc-number">1.</span> <span class="toc-text">Ex10.20</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-21"><span class="toc-number">2.</span> <span class="toc-text">Ex10.21</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Exercises-Section-10-3-4"><span class="toc-number"></span> <span class="toc-text">Exercises Section 10.3.4</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-22"><span class="toc-number">1.</span> <span class="toc-text">Ex10.22</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-23"><span class="toc-number">2.</span> <span class="toc-text">Ex10.23</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-24"><span class="toc-number">3.</span> <span class="toc-text">Ex10.24</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-25"><span class="toc-number">4.</span> <span class="toc-text">Ex10.25</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Exercises-Section-10-4-1"><span class="toc-number"></span> <span class="toc-text">Exercises Section 10.4.1</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-26"><span class="toc-number">1.</span> <span class="toc-text">Ex10.26</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-27"><span class="toc-number">2.</span> <span class="toc-text">Ex10.27</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-28"><span class="toc-number">3.</span> <span class="toc-text">Ex10.28</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Exercises-Section-10-4-3"><span class="toc-number"></span> <span class="toc-text">Exercises Section 10.4.3</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-34"><span class="toc-number">1.</span> <span class="toc-text">Ex10.34</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-35"><span class="toc-number">2.</span> <span class="toc-text">Ex10.35</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-36"><span class="toc-number">3.</span> <span class="toc-text">Ex10.36</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-37"><span class="toc-number">4.</span> <span class="toc-text">Ex10.37</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Exercises-Section-10-5-1"><span class="toc-number"></span> <span class="toc-text">Exercises Section 10.5.1</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-38"><span class="toc-number">1.</span> <span class="toc-text">Ex10.38</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-39"><span class="toc-number">2.</span> <span class="toc-text">Ex10.39</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-40"><span class="toc-number">3.</span> <span class="toc-text">Ex10.40</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Exercises-Section-10-5-3"><span class="toc-number"></span> <span class="toc-text">Exercises Section 10.5.3</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-41"><span class="toc-number">1.</span> <span class="toc-text">Ex10.41</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Exercises-Section-10-6"><span class="toc-number"></span> <span class="toc-text">Exercises Section 10.6</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ex10-42"><span class="toc-number">1.</span> <span class="toc-text">Ex10.42</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/blog/2022/05/17/%E3%80%8A%E7%AE%97%E6%B3%95%E8%AE%BE%E8%AE%A1%E6%89%8B%E5%86%8C%E3%80%8B%E9%9D%A2%E8%AF%95%E9%A2%98%EF%BC%9AChapter-1/" title="《算法设计手册》面试题：Chapter 1">《算法设计手册》面试题：Chapter 1</a><time datetime="2022-05-17T07:35:05.000Z" title="发表于 2022-05-17 15:35:05">2022-05-17</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/blog/2022/05/14/Wireshark-Lab-DHCP-v7-0/" title="Wireshark Lab: DHCP v7.0">Wireshark Lab: DHCP v7.0</a><time datetime="2022-05-14T07:19:53.000Z" title="发表于 2022-05-14 15:19:53">2022-05-14</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/blog/2022/05/14/Wireshark-Lab-Ethernet-and-ARP-v7-0/" title="Wireshark Lab: Ethernet and ARP v7.0">Wireshark Lab: Ethernet and ARP v7.0</a><time datetime="2022-05-14T07:18:10.000Z" title="发表于 2022-05-14 15:18:10">2022-05-14</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/blog/2022/05/14/Wireshark-Lab-ICMP-v7-0/" title="Wireshark Lab: ICMP v7.0">Wireshark Lab: ICMP v7.0</a><time datetime="2022-05-14T07:16:41.000Z" title="发表于 2022-05-14 15:16:41">2022-05-14</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/blog/2022/05/14/Wireshark-Lab-NAT-v7-0/" title="Wireshark Lab: NAT v7.0">Wireshark Lab: NAT v7.0</a><time datetime="2022-05-14T07:15:13.000Z" title="发表于 2022-05-14 15:15:13">2022-05-14</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2022 By astralcon</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="algolia-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="search-wrap"><div id="algolia-search-input"></div><hr/><div id="algolia-search-results"><div id="algolia-hits"></div><div id="algolia-pagination"></div><div id="algolia-info"><div class="algolia-stats"></div><div class="algolia-poweredBy"></div></div></div></div></div><div id="search-mask"></div></div><div><script src="/blog/js/utils.js"></script><script src="/blog/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js"></script><script src="https://cdn.jsdelivr.net/npm/algoliasearch@4/dist/algoliasearch-lite.umd.js"></script><script src="https://cdn.jsdelivr.net/npm/instantsearch.js@4/dist/instantsearch.production.min.js"></script><script src="/blog/js/search/algolia.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>function loadValine () {
  function initValine () {
    const valine = new Valine(Object.assign({
      el: '#vcomment',
      appId: 'Uh3CYGE2t1Eaz4KoTkyVQv1N-gzGzoHsz',
      appKey: '1Gdg4rGlmT4Dcfv7oNiCH1q3',
      avatar: 'monsterid',
      serverURLs: '',
      emojiMaps: "",
      path: window.location.pathname,
      visitor: false
    }, null))
  }

  if (typeof Valine === 'function') initValine() 
  else getScript('https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js').then(initValine)
}

if ('Valine' === 'Valine' || !false) {
  if (false) btf.loadComment(document.getElementById('vcomment'),loadValine)
  else setTimeout(loadValine, 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script><script>function loadDisqus () {
  var disqus_config = function () {
    this.page.url = 'https://astralcon.gitee.io/blog/2022/05/14/Chapter-10-Generic-Algorithms/'
    this.page.identifier = '2022/05/14/Chapter-10-Generic-Algorithms/'
    this.page.title = 'Chapter 10: Generic Algorithms'
  };

  window.disqusReset = () => {
    DISQUS.reset({
      reload: true,
      config: disqus_config
    })
  }

  if (window.DISQUS) disqusReset()
  else {
    (function() { 
      var d = document, s = d.createElement('script');
      s.src = 'https://.disqus.com/embed.js';
      s.setAttribute('data-timestamp', +new Date());
      (d.head || d.body).appendChild(s);
    })();
  }
}

if ('Valine' === 'Disqus' || !false) {
  if (false) btf.loadComment(document.getElementById('disqus_thread'), loadDisqus)
  else loadDisqus()
} else {
  function loadOtherComment () {
    loadDisqus()
  }
}
</script></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script src="/blog/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body></html>